#override("title")
SpringWind - 场地列表
#end
#override("css")
<link href="#springUrl('/static/css/plugins/bootstrap-table/bootstrap-table.min.css')" rel="stylesheet">
<link href="#springUrl('/static/css/less/style.css')" rel="stylesheet">
<style type="text/css">
	.d1{
		padding-right: 50%;
	}
	.d2{
		padding-right: 20%;
	}
	.black_overlay{
		display: none;
		position: absolute;
		top: 0%;
		left: 0%;
		width: 100%;
		height: 100%;
		background-color: black;
		z-index:1001;
		-moz-opacity: 0.8;
		opacity:.80;
		filter: alpha(opacity=88);
	}
	.white_content {
		display: none;
		position: absolute;
		top: 25%;
		left: 25%;
		width: 65%;
		height: 20%;
		padding: 0%;
		background-color: white;
		z-index:1002;
		overflow: auto;
	}
	.threatTop{
		top: 0%;
		left: 0%;
		padding: 0;
		margin: 0;
		width: 100%;
		height: 10%;
		background-color: #F8F8F8;
	}
	.tableThreat{
		table-layout:fixed;
		empty-cells:show;
		border-collapse: collapse;
		margin:0 auto;
		border:1px solid #cad9ea;
		color:#666;
	}
	.tableThreat th {
		font: bold 12px "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;
		color: #4f6b72;
		border-right: 1px solid #C1DAD7;
		border-bottom: 1px solid #C1DAD7;
		border-top: 1px solid #C1DAD7;
		letter-spacing: 2px;
		text-transform: uppercase;
		text-align: left;
		padding: 6px 6px 6px 12px;
		background: #CAE8EA no-repeat;
	}
	.tableThreat td,.table th{
		border-right: 1px solid #C1DAD7;
		border-bottom: 1px solid #C1DAD7;
		background: #fff;
		font-size:14px;
		padding: 6px 6px 6px 12px;
		color: #4f6b72;
	}
	.tableThreat tr.alter{
		background-color:#f5fafe;
	}
</style>
#end
#override("breadcrumb")
<li><a>评分系统</a></li><li class="active"><strong>场地列表</strong><strong>$!{province}</strong><strong>$!{city}</strong></li>

<div class="container">
	<ul class="nav nav-pills nav-justified step step-arrow">
		<li>
			<a href="#springUrl('/examine/source')/${siteId}/0">污染物</a>
		</li>
		<li>
			<a href="#springUrl('/examine/ground')/${siteId}/0">地下水</a>
		</li>
		<li>
			<a href="#springUrl('/examine/surfaceIndex')/${siteId}/0/0/0">地表水</a>
		</li>
		<li>
			<a href="#springUrl('/examine/soil')/${siteId}">土壤</a>
		</li>
		<li>
			<a href="#springUrl('/examine/air')/${siteId}">空气</a>
		</li>
	</ul>
</div>

#end
#override("content")
<div class="ibox-content" style="margin:3%;padding: 5% 10%">
	<form id="myForm" class="form-horizontal" autocomplete="off" data-validator-option="{theme:'default'}">
		<div class="form-group"><label class=" control-label" style="margin: 0 auto;">污染物释放可能性因子值:</label>
		</div>
		<div class="form-group"><label class="col-sm-2 control-label" >1.污染物释放可能性因子值:</label>
			<div class="col-sm-10 d2">
				<!--<input type="hidden" class="form-control" name="ObsRelease" >-->
				<select name="ObsRelease" class="form-control" id="Obs_release"style="width: 50%">
					<option>0</option>
					<option>550</option>
				</select>
			</div>
		</div>
		<div class="hr-line-dashed"></div>
		<div class="form-group"><label class=" control-label" >2.污染物潜在释放可能性因子值:</label>
		</div>
		<div class="form-group"><label class="col-sm-2 control-label">2a.气体污染物释放可能性因子值:</label>
			<div class="col-sm-10 d1">
				<input type="text" class="form-control" id="gas_potential_to_release" name="gasPotentialToRelease"  value="$!{air.gas_potential_to_release}"   placeholder="请输入因子值" data-rule="气体污染物释放可能性因子值:required;gas_potential_to_release" readonly>
				<div class="alert alert-warning alert-dismissible" role="alert" style="display: none" id="2aErrMsg">
					<!--data-dismiss="alert" aria-label="Close"-->
					<button type="button" class="close"  id="2aMsg" onclick="closeErr(this.id)"><span aria-hidden="true">&times;</span></button>
					<strong>错误!</strong> 请输入正确数值！(0-500)
				</div>
			</div>
		</div>
		<div class="form-group"><label class="col-sm-2 control-label">2b.颗粒物污染物释放可能性因子值:</label>
			<div class="col-sm-10 d1">
				<input type="text" class="form-control" id="particulate_poten_to_release" name="particulatePotenToRelease"  value="$!{air.particulate_poten_to_release}"   placeholder="请输入因子值" data-rule="颗粒物污染物释放可能性因子值:required;particulate_poten_to_release" readonly>
				<div class="alert alert-warning alert-dismissible" role="alert" style="display: none" id="2bErrMsg">
					<!--data-dismiss="alert" aria-label="Close"-->
					<button type="button" class="close"  id="2bMsg" onclick="closeErr(this.id)"><span aria-hidden="true">&times;</span></button>
					<strong>错误!</strong> 请输入正确数值！(0-500)
				</div>
			</div>
		</div>
		<div class="form-group"><label class="col-sm-2 control-label">2c.污染物潜在释放可能性因子值:</label>
			<div class="col-sm-10 d1">
				<input type="text" class="form-control" id="potential_to_release" name="potentialToRelease"  value="#if ( $air.potential_to_release ) $!{air.potential_to_release}  #else  0  #end" readonly>
			</div>
		</div>
		<div class="form-group"><label class="col-sm-2 control-label">3.污染物释放可能性因子值:</label>
			<div class="col-sm-10 d1">
				<input type="text" class="form-control" id="likelihood_of_release" name="likelihoodOfRelease"  value="#if ( $air.likelihood_of_release ) $!{air.likelihood_of_release}  #else  0  #end" readonly>
			</div>
		</div>
		<div class="hr-line-dashed"></div>
		<div class="form-group"><label class="col-sm-2 control-label" >废物特征:</label>
		</div>
		<div class="form-group"><label class="col-sm-2 control-label">4.毒性:
			<button class="btn btn-info" onclick="openThreat('Threat','Fade');return false;">移动性</button>
		</label>


			<div id="Threat" class="white_content">
				<div class="threatTop">
					<a href = "javascript:void(0)" onclick = "closeThreat('Threat','Fade')" >
						<p style="font-size: 30px;margin-left:95%;display: inline">×</p></a>
				</div>
				<div class="col-sm-10 d2" style="width: 100%;margin-top: 5%">
					<div style="display: inline;float: left;width: 50%;margin-left: 7%">
						<label class=" control-label" style="margin: 0 auto">选择主要元素:</label><br>
						<select id="threat1" multiple="multiple" size="6"  class="form-control"style="height: 10%;display: inline">
						</select>

					</div>
					<div style="display: inline;float: right">

						<label class=" control-label" style="margin: 0 auto">选择流动方式:</label><br>
						<input type="radio" name="mob_type" value="gaseous" id="gaseous" onclick=changeThreat('threat1','mobType','gaseous')><label style="font-size: 15px;margin-left: 3px">气态</label><br>
						<input type="radio" name="mob_type" value="particulate" id="particulate" onclick=changeThreat('threat1','mobType','particulate')><label style="font-size: 15px;margin-left: 3px">颗粒</label><br>
						<!--<button class="btn btn-info" type="button" onclick = "closeThreat('Threat','Fade');maxPersistenceCaculate('PerTox','substance','persistence','has_waste_quantity');return false;" >
							保存并返回</button>-->
					</div>
				</div>
				<div style="padding-top: 30%;">
					<table width="90%" class="tableThreat" id="tableThreat">

					</table>
				</div>
			</div>
			<div id="Fade" class="black_overlay"></div>





			<div class="col-sm-10 d1">
				<input type="text" class="form-control" name="persistence" id="persistence"   readonly>
			</div>
		</div>

		<div class="form-group"><label class="col-sm-2 control-label">使用物质:</label>
			<div class="col-sm-10 d2">
				<!--<input type="hidden" class="form-control" name="substance"  >-->
				<select name="substance" id="substance" class="form-control"style="width: 50%">
					<!--<option>Aldrin</option>
					<option>Benzidine</option>-->
				</select>
			</div>
		</div>
		<div class="form-group"><label class="col-sm-2 control-label">5.有害废物量:<a onclick="surface(this.name)" name="2-6">(2-6)</a></label>
			<div class="col-sm-10 d1">
				<input type="text" class="form-control" name="hasWasteQuantity" id="has_waste_quantity"  value="$!{air.has_waste_quantity}" readonly>
			</div>
		</div>
		<div class="form-group"><label class="col-sm-2 control-label">6.废物特征:<a onclick="surface(this.name)" name="2-7">(2-7)</a></label>
			<div class="col-sm-10 d1">
				<input type="text" class="form-control" id="waste_characteristics" name="wasteCharacteristics"  value="$!{air.waste_characteristics}" readonly>
			</div>
		</div>
		<div class="hr-line-dashed"></div>
		<div class="form-group"><label class="col-sm-2 control-label" >目标因子值:</label>
		</div>
		<div class="form-group"><label class="col-sm-2 control-label">7.最近个人目标因子值:<a onclick="surface(this.name)" name="6-16">(6-16)</a></label>
			<div class="col-sm-10 d2">
				<!--<input type="hidden" class="form-control" name="nearest_intake"  >-->
				<select name="nearestIntake" id="nearest_intake" class="form-control"style="width: 50%">
					<option>0</option>
					<option>1</option>
					<option>2</option>
					<option>7</option>
					<option>20</option>
					<option>45</option>
					<option>50</option>
				</select>
			</div>
		</div>
		<div class="form-group"><label class="col-sm-2 control-label" >8.人口目标因子值:</label>
		</div>
		<div class="form-group"><label class="col-sm-2 control-label">8a.暴露于水平1浓度的人口数量：</label>
			<div class="col-sm-10 d1">
				<input type="text"  class="form-control" id="pop_concent1" name="popConcent1"  placeholder="请输入该目标因子值" data-rule="人口目标因子值1:required;pop_concent1" value="$!{air.pop_concent1}" readonly>
				<div class="alert alert-warning alert-dismissible" role="alert" style="display: none" id="8aErrMsg">
					<!--data-dismiss="alert" aria-label="Close"-->
					<button type="button" class="close"  id="8aMsg" onclick="closeErr(this.id)"><span aria-hidden="true">&times;</span></button>
					<strong>错误!</strong> 请输入正确数值！
				</div>
			</div>
		</div>
		<div class="form-group"><label class="col-sm-2 control-label">8b.暴露于水平2浓度的人口数量：</label>
			<div class="col-sm-10 d1">
				<input type="text"  class="form-control" id="pop_concent2" name="popConcent2"  placeholder="请输入该目标因子值" data-rule="人口目标因子值1:required;pop_concent2" value="$!{air.pop_concent2}" readonly>
				<div class="alert alert-warning alert-dismissible" role="alert" style="display: none" id="8bErrMsg">
					<!--data-dismiss="alert" aria-label="Close"-->
					<button type="button" class="close"  id="8bMsg" onclick="closeErr(this.id)"><span aria-hidden="true">&times;</span></button>
					<strong>错误!</strong> 请输入正确数值！
				</div>
			</div>
		</div>
		<div class="form-group"><label class="col-sm-2 control-label">8c.暴露于潜在污染的标准人口数量：<a onclick="surface(this.name)" name="6-17">(6-17)</a></label>
			<div class="col-sm-10 d1">
				<input type="text"  class="form-control" id="pot_concent" name="potConcent"  placeholder="请输入该目标因子值" data-rule="人口目标因子值1:required;pot_concent" value="$!{air.pot_concent}" readonly>
				<div class="alert alert-warning alert-dismissible" role="alert" style="display: none" id="8cErrMsg">
					<!--data-dismiss="alert" aria-label="Close"-->
					<button type="button" class="close"  id="8cMsg" onclick="closeErr(this.id)"><span aria-hidden="true">&times;</span></button>
					<strong>错误!</strong> 请输入正确数值！
				</div>
			</div>
		</div>
		<div class="form-group"><label class="col-sm-2 control-label">8d.人口目标因子值:</label>
			<div class="col-sm-10 d1">
				<input type="text" class="form-control" id="population" name="population"  value="#if ( $air.population ) $!{air.population}  #else  0  #end" readonly>
			</div>
		</div>
		<div class="form-group"><label class="col-sm-2 control-label">9.资源目标因子值:</label>
			<div class="col-sm-10 d2">
				<!--<input type="hidden" class="form-control" name="resource"  >-->
				<select name="resources" id="resource" class="form-control"style="width: 50%">
					<option>0</option>
					<option>5</option>
				</select>
			</div>
		</div>
		<div class="form-group"><label class="col-sm-2 control-label" >10.敏感环境目标因子值:</label>
		</div>
		<div class="form-group"><label class="col-sm-2 control-label">10a.动植物敏感环境目标因子值：&nbsp;<a onclick="surface(this.name)" name="4-23">(4-23)</a></label>
			<div class="col-sm-10 d1">
				<input type="text"  class="form-control" id="actual_contamination" name="actualContamination"  placeholder="请输入该目标因子值" data-rule="敏感环境目标因子值:required;actual_contamination" value="$!{air.actual_contamination}" readonly>
				<div class="alert alert-warning alert-dismissible" role="alert" style="display: none" id="10aErrMsg">
					<!--data-dismiss="alert" aria-label="Close"-->
					<button type="button" class="close"  id="10aMsg" onclick="closeErr(this.id)"><span aria-hidden="true">&times;</span></button>
					<strong>错误!</strong> 请输入正确数值！
				</div>
			</div>
		</div>
		<div class="form-group"><label class="col-sm-2 control-label">10b.湿地敏感环境目标因子值：<a onclick="surface(this.name)" name="6-18">(6-18)</a></label>
			<div class="col-sm-10 d1">
				<input type="text"  class="form-control" id="potential_contamination" name="potentialContamination"  placeholder="请输入该目标因子值" data-rule="敏感环境目标因子值:required;potential_contamination" value="$!{air.potential_contamination}" readonly>
				<div class="alert alert-warning alert-dismissible" role="alert" style="display: none" id="10bErrMsg">
					<!--data-dismiss="alert" aria-label="Close"-->
					<button type="button" class="close"  id="10bMsg" onclick="closeErr(this.id)"><span aria-hidden="true">&times;</span></button>
					<strong>错误!</strong> 请输入正确数值！
				</div>
			</div>
		</div>
		<div class="form-group"><label class="col-sm-2 control-label">10c.敏感环境目标因子值:</label>
			<div class="col-sm-10 d1">
				<input type="text" class="form-control" id="sensitive_environments" name="sensitiveEnvironments"  value="#if ( $air.sensitive_environments ) $!{air.sensitive_environments}  #else  0  #end" readonly>
			</div>
		</div>
		<div class="form-group"><label class="col-sm-2 control-label">11.目标因子值:</label>
			<div class="col-sm-10 d1">
				<input type="text" class="form-control" id="targets" name="targets"  value="#if ( $air.targets ) $!{air.targets}  #else  0  #end" readonly>
			</div>
		</div>
		<div class="hr-line-dashed"></div>
		<div class="form-group"><label class=" control-label" >空气暴露途径评分:</label>
		</div>
		<div class="form-group"><label class="col-sm-2 control-label">12.空气暴露途径评分:</label>
			<div class="col-sm-10 d1">
				<input type="text" class="form-control" id="air_pathway_score" name="airPathwayScore"  value="$!{air.air_pathway_score}" readonly>
			</div>
		</div>
		<div class="form-group"><label class="col-sm-2 control-label" >未经扫描得分:</label>
			<div class="col-sm-10 d1">
				<input type="text" class="form-control" id="uncapped_score" name="uncappedScore"  value="$!{air.uncapped_score}" readonly>
			</div>
		</div>
		<div class="hr-line-dashed"></div>
		<div class="form-group">
			<div class="text-center">
				<a class="btn btn-primary btn-next" href="#springUrl('/examine/soil/')${siteId}" >  <  </a>
				<!-- <button class="btn btn-primary" type="submit">保 存</button>-->
				<a class="btn btn-default btn-next" href="#" >  >  </a>
			</div>
		</div>
	</form>
</div>
<script src="#springUrl('/static/js/base_list.js')"></script>
<script src="#springUrl('/static/js/common.js')"></script>
<script src="#springUrl('/static/js/jquery-2.1.1.js')"></script>
<script src="#springUrl('/static/plugins/layer-v2.2/layer/layer.js')"></script>
<script src="#springUrl('/static/js/lib/less.js')"></script>
<script src="#springUrl('/static/js/lib/jquery.min.js')"></script>
<script src="#springUrl('/static/js/lib/lib.js')"></script>
<script src="#springUrl('/static/plugins/nice-validator-0.8.1/jquery.validator.js?local=zh-CN')"></script>

<script type="text/javascript">

    //var air = JSON.parse('${air}');
    var siteId  = '${siteId}';

   /* $("#myForm").validator({
        valid: function(form){
            var me = this;
            // 提交表单之前，hold住表单，防止重复提交
            me.holdSubmit();

            for(t = 0;t<dList.length;t++){
                dList[t].select_type = JSON.stringify(type[t]).replace(/\"/g,'\\"');
            }

            $.ajax({
                url: "#springUrl('/air/caculateScore/"+siteId+"')",
                data: $.param({'dList':JSON.stringify(dList)})+'&'+$(form).serialize(),
                type: "POST",
                success: function(data){
                    parent.layer.alert("保存成功",function(){
                        parent.layer.closeAll();
                        // window.parent.location.reload();
                    });
                    /!* var d = JSON.parse(data);
                     if(d.success && d.data){
                         window.parent.location.reload();
                         //当你在iframe页面关闭自身时
                         //var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                         //parent.layer.close(index); //再执行关闭
                     } else {
                         //失败，提交表单成功后，释放hold，如果不释放hold，就变成了只能提交一次的表单
                         me.holdSubmit(false);
                     }*!/
                }
            });
        }
    });*/
    function surface(id) {
        // alert("哈哈哈");
        //	alert(id);
        var title = "表"+id;
        var url = "#springUrl('/air/surface"+id+".html')";
        layer.open({
            type: 2,
            title: title,
            shadeClose: true,
            shade: 0.8,
            area: ['860px', '430px'],
            fix: false,
            maxmin: false,
            content: url
        });
    }


    var potentialToRelease = $('#potential_to_release');
    var gasPotentialToRelease = $('#gas_potential_to_release');
    var particulatePotenToRelease = $('#particulate_poten_to_release');
    var likelihoodOfRelease = $('#likelihood_of_release');
    var ObsRelease = $('#Obs_release');
    var potConcent = $('#pot_concent');
    var popConcent1 = $('#pop_concent1');
    var popConcent2 = $('#pop_concent2');
    var population = $('#population');
    var actualContamination = $('#actual_contamination');
    var potentialContamination = $('#potential_contamination');
    var sensitiveEnvironments = $('#sensitive_environments');
    var targets = $('#targets');
    var nearestIntake = $('#nearest_intake');
    var resource = $('#resource');
    var wasteCharacteristics = $('#waste_characteristics');
    var airPathwayScore = $('#air_pathway_score');
    var uncappedScore = $('#uncapped_score');
    var gaseous = document.getElementById('gaseous');
    var particulate = document.getElementById('particulate');
    var tableThreat = document.getElementById('tableThreat');
    var dList = JSON.parse('${dangerouSelect}');
    var type = new Array;
    for(t = 0;t<dList.length;t++) {
        if(dList[t].select_type!=null){
            type[t] = JSON.parse(dList[t].select_type);
        }else{
            type[t] = new Object();
            type[t].mobType = 'gaseous';
        }
    }

    $(function () {
        bsStep(5);
        decodeMessage();
        maxPersistenceCaculate('PerTox','substance','persistence','has_waste_quantity');
        selectIn(ObsRelease,'${air.Obs_release}');
        selectIn(nearestIntake,'${air.nearest_intake}');
        selectIn(resource,'${air.resources}');
        gasPotentialToRelease.change(function () {
            if(!isDigit(parseInt(gasPotentialToRelease.val()))||gasPotentialToRelease.val()<0||gasPotentialToRelease.val()>500){
                gasPotentialToRelease.val(0);
                openErr('2a');
            }else {
                closeErr('2aMsg');
            }
            caculatePotentialToRelease();
        });
        particulatePotenToRelease.change(function () {
            if(!isDigit(parseInt(particulatePotenToRelease.val()))||particulatePotenToRelease.val()<0||particulatePotenToRelease.val()>500){
                particulatePotenToRelease.val(0);
                openErr('2b');
            }else {
                closeErr('2bMsg');
            }
            caculatePotentialToRelease();
        });
        ObsRelease.change(function () {
            caculateLikelihoodOfRelease();
        });
        popConcent1.change(function () {
            if(!isDigit(parseInt(popConcent1.val()))||popConcent1.val()<0){
                popConcent1.val(0);
                openErr('8a');
            }else {
                closeErr('8aMsg');
            }
            caculatePopulation();
        });
        popConcent2.change(function () {
            if(!isDigit(parseInt(popConcent2.val()))||popConcent2.val()<0){
                popConcent2.val(0);
                openErr('8b');
            }else {
                closeErr('8bMsg');
            }
            caculatePopulation();
        });
        potConcent.change(function () {
            if(!isDigit(parseInt(potConcent.val()))||potConcent.val()<0){
                potConcent.val(0);
                openErr('8c');
            }else {
                closeErr('8cMsg');
            }
            caculatePopulation();
        });
        actualContamination.change(function () {
            if(!isDigit(parseInt(actualContamination.val()))||actualContamination.val()<0){
                actualContamination.val(0);
                openErr('10a');
            }else {
                closeErr('10aMsg');
            }
            caculateSensitiveEnvironments();
        });
        potentialContamination.change(function () {
            if(!isDigit(parseInt(potentialContamination.val()))||potentialContamination.val()<0){
                potentialContamination.val(0);
                openErr('10b');
            }else {
                closeErr('10bMsg');
            }
            caculateSensitiveEnvironments();
        });
        nearestIntake.change(function () {
            caculateTargets();
        });
        resource.change(function () {
            caculateTargets();
        });
        wasteCharacteristics.change(function () {
            caculateScore();
        });
    });



    function decodeMessage(){
        var tmp="";
        var tdd="<tr><th>元素</th><th>毒性</th><th>流动方式</th><th>流动值</th><th>毒性/持久性</th></tr>";
        var mob_value = 0;
        var mob_name ;
        for(i=0;i<dList.length;i++){
            tmp+="<option onclick = getOption("+i+") >"+dList[i].chnname+"</option>";

            if(type[i].mobType=="gaseous"){
                mob_value = 1;
                mob_name = '气态';
            }else if(type[i].mobType=="particulate"){
                mob_value = 0.02;
                mob_name = '颗粒';
            }

            tdd+="<tr><td>"+dList[i].chnname+"</td><td id='tox"+i+"'>"+dList[i].tox+"</td><td id='mobName"+i+"'>"+mob_name+"</td><td id='mobValue"+i+"'>"+mob_value+"</td><td id='PerTox"+i+"'>"+(mob_value*dList[i].tox).toFixed(0)+ "</td></tr>";

        }

        document.getElementById("threat1").innerHTML=tmp;
        tableThreat.innerHTML=tdd;

    }

    function caculatePotentialToRelease() {
        potentialToRelease.val(gasPotentialToRelease.val()>particulatePotenToRelease.val()?gasPotentialToRelease.val():particulatePotenToRelease.val());
        caculateLikelihoodOfRelease();
    }
    function caculateLikelihoodOfRelease() {
        if(ObsRelease.val()==550){
            likelihoodOfRelease.val(550);
            caculateScore();
        }else {
            likelihoodOfRelease.val(potentialToRelease.val());
            caculateScore();
        }
    }
    function caculatePopulation() {
        population.val(popConcent1.val()*10+popConcent2.val()*1+potConcent.val()*0.1);
        caculateTargets();
    }
    function caculateSensitiveEnvironments() {
        sensitiveEnvironments.val(actualContamination.val()*1+potentialContamination.val()*0.1);
        caculateTargets();
    }
    function caculateTargets() {
        targets.val(nearestIntake.val()*1+population.val()*1+resource.val()*1+sensitiveEnvironments.val()*1);
        caculateScore();
    }
    function caculateScore() {

        uncappedScore.val(((likelihoodOfRelease.val()*wasteCharacteristics.val()*targets.val())/82500).toFixed(2));
        if(uncappedScore.val()>100){
            airPathwayScore.val(100);
        }else {
            airPathwayScore.val(uncappedScore.val());
        }
    }
    function openErr(id) {
        //alert(id);
        $('#'+id+'ErrMsg').css('display','block');
    }
    function closeErr(id) {
        $('#'+id).parent().css('display','none');
    }
    function isDigit(s)
    {
        var patrn=/^[0-9]{1,20}$/;
        if (!patrn.exec(s)) {
            // alert("false");
            return false;
        }
        // alert("true");
        return true;
    }

    function selectIn(key,value) {
        key.children("option").each(function(){
            var temp_value = $(this).val();
            if(temp_value == value){
                $(this).attr("selected","selected");
                key.attr('readonly','readonly');
            }
        });
    }

    function  openThreat(id,fade) {
        var light = document.getElementById(id);
        var top =  document.documentElement.scrollTop;
        light.style.display='block';
        document.getElementById(fade).style.display='block';
        // light.style.top = (document.documentElement.clientHeight-light.height)/2+top + 'px';
        light.style.top = top+light.style.height/2 -50 + 'px' ;
    }

    function closeThreat(id,fade) {
        var light = document.getElementById(id);
        light.style.display='none';
        var fadeD = document.getElementById(fade);
        fadeD.style.display='none';
    }

    //按保存后再获取最大值
    function maxPersistenceCaculate(tox,substance,persistence,quantity) {
        var sub = document.getElementById(substance);
        var toxcity1 = new Array;
        var maxPersistence1 = 0;
        var maxPersistenceId1 = new Array;
        var maxId1=1;
        for(t = 0;t<dList.length;t++){
            toxcity1[t] = document.getElementById(tox+t).innerText;
            if( parseFloat(toxcity1[t])>parseFloat(maxPersistence1)){
                maxPersistence1= toxcity1[t];
                maxPersistenceId1.slice(0,maxPersistenceId1.length);
                maxPersistenceId1[0] =  t;
                maxId1=1;
            }else if( parseFloat(toxcity1[t])==parseFloat(maxPersistence1)){
                maxPersistenceId1[maxId1] = t;
                maxId1++;
            }
        }
        $("#"+persistence).val(maxPersistence1);
        caculateHasWasteQuantity($("#"+quantity),maxPersistence1);

        var op1 = "";
        for (i=0;i<maxPersistenceId1.length;i++){
            op1+="<option>"+dList[maxPersistenceId1[i]].chnname+"</option>";
        }
        sub.innerHTML = op1;
    }

    function caculateHasWasteQuantity(quantity,persistence) {

        if(parseFloat(persistence)<=0){
            quantity.val(0);
        }else if(parseFloat(persistence)>0&&parseFloat(persistence)<=100){
            quantity.val(1);
        }else if(parseFloat(persistence)>100&&parseFloat(persistence)<=10000){
            quantity.val(100);
        }else if(parseFloat(persistence)>10000&&parseFloat(persistence)<=1000000){
            quantity.val(10000);
        }else if(parseFloat(persistence)>1000000){
            quantity.val(1000000);
        }
        caculateCharacteristics(quantity,persistence);
    }

    function caculateCharacteristics(quantity,persistence) {
        var t = quantity.val()*persistence;
        if(t ==0){
            wasteCharacteristics.val(0);
        }else if(t>0&&t<10){
            wasteCharacteristics.val(1);
        }else if(t>=10&&t<100){
            wasteCharacteristics.val(2);
        }else if(t>=100&&t<1000){
            wasteCharacteristics.val(3);
        }else if(t>=1000&&t<10000){
            wasteCharacteristics.val(6);
        }else if(t>=10000&&t<100000){
            wasteCharacteristics.val(10);
        }else if(t>=100000&&t<1000000){
            wasteCharacteristics.val(18);
        }else if(t>=1000000&&t<10000000){
            wasteCharacteristics.val(32);
        }else if(t>=10000000&&t<100000000){
            wasteCharacteristics.val(56);
        }else if(t>=100000000&&t<1000000000){
            wasteCharacteristics.val(100);
        }else if(t>=1000000000&&t<10000000000){
            wasteCharacteristics.val(180);
        }else if(t>=10000000000&&t<100000000000){
            wasteCharacteristics.val(320);
        }else if(t>=100000000000&&t<1000000000000){
            wasteCharacteristics.val(560);
        }else if(t>=1000000000000){
            wasteCharacteristics.val(1000);
        }
        caculateScore();
    }

    function changeThreat(id,key,value) {
        var myselect = document.getElementById(id);
        //获取大选择框即毒素名的选择
        var index = myselect.selectedIndex;
        var tox = document.getElementById('tox'+index).innerText;
        //赋值于type中，使之不会跳转回原来的选项
        type[index][key] = value;

        if(value=="gaseous"){
            document.getElementById("mobValue"+index).innerHTML=1;
            document.getElementById("mobName"+index).innerHTML='气态';
            document.getElementById("PerTox"+index).innerHTML=tox;
        }else  if(value=="particulate"){
            document.getElementById("mobValue"+index).innerHTML=0.02;
            document.getElementById("mobName"+index).innerHTML='颗粒';
            document.getElementById("PerTox"+index).innerHTML=(tox*0.02).toFixed(0);
        }


    }

    function getOption(i) {
        if (type[i].mobType=='gaseous'){
            gaseous.checked='checked';
        }else if(type[i].mobType=='particulate'){
            particulate.checked='checked';
        }
    }
</script>
#end
#extends("/common/framework.html")
